<!--
 /**
 * Author: hongChengHao
 * Date: 2022-07-26 19:41
 * Desc: 观影人列表
 */
-->
<template>
  <yy-page class="customer-list">
    <view class="customer-list__title">观影人列表</view>
    <view class="customer-list__content">
      <block v-for="item in list" :key="item.realNameId">
        <view class="customer-list__items fs32">
          <view class="flex-1">
            <text v-if="false"></text>
            <text>{{ item.realName }}</text>
            <text class="fc8 ml10 fs28">{{ item.idCardNo }}</text>
          </view>
          <view>
            <u-icon name="trash" size="18" @click="onDel(item.realNameId)"></u-icon>
          </view>
        </view>
      </block>
      <view class="customer-list__add blue" @click="toCustomerAdd"> +新增观影人 </view>
    </view>
  </yy-page>
</template>
<script>
  export default {
    name: 'customer-list',
    data() {
      return {
        list: []
      }
    },
    onLoad() {
      this.getRealNameList()
    },
    methods: {
      getRealNameList() {
        uni.$api.user.getRealNameList().then((res) => {
          this.list = res.list || []
        })
      },
      onDel(id) {
        this.$msg.showModal('是否删除该观影人信息').then(() => {
          uni.$api.user.delRealName({ realNameId: id }).then(() => {
            this.getRealNameList()
            this.$msg.toast('删除成功!')
          })
        })
      },
      toCustomerAdd() {
        this.$tools.navigateTo('/subPages/customerAdd/index')
      }
    }
  }
</script>
<style lang="scss" scoped>
  .customer-list {
    &__title {
      padding: 20rpx;
      font-weight: bold;
      font-size: 32rpx;
    }
    &__content {
      background: #fff;
    }
    &__items {
      display: flex;
      padding: 20rpx 50rpx;
      border-bottom: 1rpx solid #eee;
    }
    &__add {
      text-align: center;
      padding: 20rpx 0;
    }
  }
</style>
